<template>
<!-- 财务信息 -->
<div class="panel">
    <div class="panel-header">
        <div class="bl"></div>
        <div class="title">二销</div>
        <div class="more">
            <el-button type="primary" @click="showCreateView">新增</el-button>
        </div>
    </div>
    <div class="panel-body">
        <el-table :data="suborderList" border>
            <el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
            <el-table-column label="销售" prop="user.realname" width="120" show-overflow-tooltip></el-table-column>
            <el-table-column label="项目">
                <template slot-scope="scope">
                    <div v-for="item in scope.row.bom" :key="item.id" class="product-item">
                        <el-tag size="small">{{ item.title }}/{{item.suk}}/{{item.price}}/{{item.product_unit}}</el-tag>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="消费次数" prop="consume_times" width="120"></el-table-column>
            <el-table-column label="总金额" prop="totals" width="120"></el-table-column>
            <el-table-column label="优惠金额" prop="discount" width="120"></el-table-column>
            <el-table-column label="备注" prop="remark" width="180" show-overflow-tooltip></el-table-column>
            <!-- <el-table-column label="操作" width="120" align="center" v-if="$hasRule('order-income-update')">
                <template slot-scope="scope">
                    <el-button type="primary" @click="showEditView(scope.row)">编辑-</el-button>
                </template>
            </el-table-column> -->
        </el-table>

        <suborder-create ref="createRef" @doRefresh="getList"></suborder-create>
        <suborder-edit ref="editRef" @doRefresh="getList"></suborder-edit>
    </div>
</div>
</template>

<script>
import uploadFileList from '@/components/files/index';
import suborderCreate from './suborder-create.vue'
import suborderEdit from './suborder-edit.vue'

import {
    getListApi
} from '@/api/order/suborder.js'

export default {
    components: {
        uploadFileList,
        suborderCreate,
        suborderEdit
    },
    props: {
        order: {
            type: Object,
            default: {}
        },
    },
    data() {
        return {
            suborderList: []
        };
    },
    methods: {
        getList() {
            // 获取收款信息
            getListApi({
                order_id: this.order.id
            }).then((res) => {
                this.suborderList = res.data;
            });
        },
        showCreateView() {
            this.$refs.createRef.showDrawer(this.order.id);
        },
        showEditView(row) {
            this.$refs.editRef.showDrawer(row);
        }
    },
};
</script>

<style lang="less" scoped>
.product-item {
    margin-bottom: 5px;
}
</style>
